<?php 
	require("config.php");
	$tableCmd = array (
		"create table scene_spots(tbl CHAR(32), PRIMARY KEY(tbl), keyword CHAR(32), ename CHAR(64), cname CHAR(255), distance INT, lat FLOAT, lon FLOAT, iso CHAR(3))",
		"create table scene_samples(tbl CHAR(32), id BIGINT, PRIMARY KEY(tbl,id), checkins INT, text CHAR(255), ratio FLOAT)",
		"create table holiday(iso CHAR(3), date INT, PRIMARY KEY(iso, date), text CHAR(255))"
	);
	$conn = connectDBInit() or die("Connect error");

	$sql = "drop database $DB_NAME";
	if(!mysql_query($sql, $conn))
		echo "drop fail\n";

	$sql = "create database $DB_NAME";
	mysql_query($sql, $conn) or die ("create fail \n");

	$sql = "use $DB_NAME";
	mysql_query($sql, $conn) or die ("use fail\n");

	for($i=0;$i<count($tableCmd);$i++) {
		if(! mysql_query($tableCmd[$i], $conn)) {
			$cmd = $tableCmd[$i];
			echo mysql_error();
			echo "Command $cmd Fails \n";
		}
	}

?>
